<template>
  <div>
    <el-breadcrumb separator="/">
      <el-breadcrumb-item :to="{ path: '/homepage' }">首页</el-breadcrumb-item>
      <el-breadcrumb-item>全部商品</el-breadcrumb-item>
      <el-breadcrumb-item>分类</el-breadcrumb-item>
      <el-breadcrumb-item></el-breadcrumb-item>
    </el-breadcrumb>
    <div class="List-top">
      <div class="title">分类</div>
      <el-tabs
        v-model="activeName"
        type="card"
        style="width: 1500px;line-height: 30px;font-size: 16px; margin-left: 96px;"
      >
        <el-tab-pane v-for="item in BiaoList" :key="item.category_id" :label="item.category_name"></el-tab-pane>
      </el-tabs>
    </div>
    <my-list :listData="Product" :ismore="true"></my-list>
  </div>
</template>
<script>
import API from "../api/shopp";
export default {
  data() {
    return {
      activeName: "0",
      BiaoList: [],
      Product: [],
      categoryID: [],
      currentPage: 1,
      pageSize: 15,
      todal: 0
    };
  },
  created() {
    this.List();
    this.AllProduct();
    this.getProduct();
  },
  methods: {
      watch: {
    activeName(value) {
      console.log(value);
      this.categoryID = Number(value);
      if (val === 0) {
        this.AllProduct();
        return;
      }
      this.getProduct();
    }
  }
    async List() {
      let res = await API.shoppList();
      this.BiaoList = res.category;
      this.BiaoList.unshift({
        category_id: 0,
        category_name: "全部"
      });
    },
    async AllProduct() {
      let sendData = {
        categoryID: this.categoryID,
        currentPage: this.currentPage,
        pageSize: this.pageSize
      };

      let res = await API.AllShoppList(sendData);
      this.Product = res.Product;
      console.log(this.Product);
    },
    async getProduct() {
      let sendData = {
        categoryID: this.categoryID,
        currentPage: this.currentPage,
        pageSize: this.pageSize
      };
      let ress = await API.ListShopp(sendData);
      this.Product = ress.Product;
      console.log(this.Product);
    }
  },
  
};
</script>
<style lang="scss" scoped>
.el-breadcrumb {
  width: 1500px;
  line-height: 30px;
  font-size: 16px;
  margin-left: 96px;
}
.title {
  font-size: 20px;
  font-weight: 500;
  color: #303133;
  position: relative;
  top: 10px;
  left: 92px;
}
.List-top {
  display: flex;
}
</style>
